package org.rsbot.bot;

import org.rsbot.client.Callback;
import org.rsbot.client.RSCharacter;
import org.rsbot.client.Render;
import org.rsbot.client.RenderData;
import org.rsbot.event.EventManager;
import org.rsbot.event.events.CharacterMovedEvent;
import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.script.methods.Calculations;
import org.rsbot.script.methods.MethodContext;

public class CallbackImpl
  implements Callback
{
  private final Bot bot;

  public CallbackImpl(Bot paramBot)
  {
    this.bot = paramBot;
  }

  public Bot getBot() {
    return this.bot;
  }

  public void notifyMessage(int paramInt, String paramString1, String paramString2)
  {
    MessageEvent localMessageEvent = new MessageEvent(paramString1, paramInt, paramString2);
    this.bot.getEventManager().dispatchEvent(localMessageEvent);
    if ((paramInt == 0) || (paramInt == 109)) {
      ServerMessageEvent localServerMessageEvent = new ServerMessageEvent(paramString2);
      this.bot.getEventManager().dispatchEvent(localServerMessageEvent);
    }
  }

  public void rsCharacterMoved(RSCharacter paramRSCharacter, int paramInt) {
    CharacterMovedEvent localCharacterMovedEvent = new CharacterMovedEvent(this.bot.getMethodContext(), paramRSCharacter, paramInt);
    this.bot.getEventManager().dispatchEvent(localCharacterMovedEvent);
  }

  public void updateRenderInfo(Render paramRender, RenderData paramRenderData) {
    MethodContext localMethodContext = this.bot.getMethodContext();
    if (localMethodContext != null)
      localMethodContext.calc.updateRenderInfo(paramRender, paramRenderData);
  }
}